package com.jiyun.controller;

import com.jiyun.service.RechargeService;
import com.reading.pojo.Recharge;
import com.reading.pojo.RechargeDto;
import com.reading.pojo.RechargeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/recharge")
public class RechargeController {

    @Autowired
    private RechargeService rechargeService;

    @RequestMapping("/saveRecharge")
    public void saveRecharge(@RequestBody Recharge recharge){
        rechargeService.saveRecharge(recharge);
    }

    @RequestMapping("getQrCodeUrl/{code}")
    public String getQrCodeUrl(@PathVariable("code")String code) throws Exception{
        return rechargeService.getQrCodeUrl(code);
    }

    @PostMapping("orderquery")
    public String orderquery(@RequestBody Recharge recharge) throws Exception{
        return rechargeService.orderquery(recharge);
    }

    @RequestMapping("/findOne")
    public Recharge findOne(String code){
       return rechargeService.findOne(code);
    }

    @RequestMapping("/updateOne")
    public void updateOne(@RequestBody RechargeVo rechargeVo){
        rechargeService.updateOne(rechargeVo);
    }

    @RequestMapping("/findById")
    public Recharge findById(Integer id){
        return rechargeService.findById(id);
    }

    @RequestMapping("findAll")
    public List<Recharge> findAll(@RequestBody RechargeDto rechargeDto){
        return rechargeService.findAll(rechargeDto);
    }

    @RequestMapping("/saveExchange")
    public void saveExchange(@RequestBody Recharge recharge){
        rechargeService.saveExchange(recharge);
    }

    @RequestMapping("/findAllExpenses")
    public String findAllExpenses(Integer id){
        return rechargeService.findAllExpenses(id);
    }
}
